'use strict';

exports.__esModule = true;

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var CONTENT_TYPE = exports.CONTENT_TYPE = {
  json: 'application/json;charset=utf-8',
  urlencoded: 'application/x-www-form-urlencoded;charset=utf-8'
};

var defaultHeaderProps = {
  'Content-Type': CONTENT_TYPE.urlencoded
};

/** 解析response的headers信息
 * @function processHeaders
 * @memberOf fe-lib.FetchRequest
 * @inner
 * @param headers
 * @returns {*}
 */

exports.default = function (headers) {
  var finalHeaders = Object.assign({}, defaultHeaderProps, headers);

  Object.keys(finalHeaders).forEach(function (key) {
    if (_typeof(finalHeaders[key]) === 'object') {
      finalHeaders[key] = JSON.stringify(finalHeaders[key]);
    }
  });

  return finalHeaders;
};